pp108 : Defining a Managed Component in a Web Application

Defining a Managed Component in a Web Application

This topic describes the procedure to define a managed component in a web application.


A generic Web application has a managed component associated with it. Developers writing the Web applications can use this managed component to define counters, operations and so on. They can also add sub-components to it.
To add performance counters in a specific web application, you must overwrite the setupManagedComponent method as shown below:

Overwriting the setupManagedComponent() Web service operation

public class TestWebApplication extends WebApplication
{
       protected void setupManagedComponent (IManagedComponent managedComponent)
       {
              super. setupManagedComponent (managedComponent);
              managedComponent.createPropertyBasedValueCounter("numOfActiveSessions",Messages.ACTIVE_SESSIONS_DESC,"numberOfActiveSessions",Session.class);
       }
}

Note: The call to the setupManagedComponent super class in the above code is crucial. If it is not added, then the performance counters of the base class(es) will not be created.